<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>我的持仓</title>
    <!--2.引入angularJS框架的样式； -->
    <link rel="stylesheet" href="angularjs/pagination.css">
    <!--3.引入Layer样式； -->
    <link rel="stylesheet" href="layer/layer/theme/default/layer.css">
    <!--7.引入angularJS框架-->
    <script src="angularjs/angular.min.js"></script>
    <!--8.引入angularJS的分页框架-->
    <script src="angularjs/pagination.js"></script>
    <!--9.引入cookie相关js-->
    <!--10.自己写的脚本-->
    <script>
        /*定义一个模块*/
        var app = angular.module("myApp", ['pagination']);
        app.controller("myCtrl", function ($scope, $http) {
            /*定义分页属性*/
            $scope.paginationConf = {
                currentPage: 1,
                itemsPerPage: 8, /*每页3条*/
                totalItems: 1000, /*总共有多少条*/
                perPageOptions: [5, 8, 10, 20], /*每页多少条,可选*/
                onChange: function () {
                    $scope.searchAll($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
                    $scope.getPrices();
                    $scope.selectIds = []; //点击第二页清空数组
                    $scope.checked = false; //把全选按钮改为不选
                }
            };
            $scope.getAll = function () {
                /*默认第一页,一页3条数据*/
                $scope.searchAll(1, 8);
            };
            //综合查询,带条件
            $scope.searchAll = function (pageIndex, pageSize) {
                //alert("searchAll");
                $scope.userid = $.cookie("stock_user_id");
                $http.post("/cli/pos/pageSearch?userid="+$scope.userid + "&pageIndex=" + pageIndex + "&pageSize=" + pageSize, $scope.searchCode).success(function (data) {
                    $scope.list = data.data.rows;
                    $scope.paginationConf.totalItems = data.data.total;
                });
                $scope.getPrices();
            };

            //点综合查询,调用上面的方法
            $scope.searchAll2 = function () {
                $scope.searchAll($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);
                //alert("searchAll2");
            };
            $scope.getPrices = function () {
                $http.post("/cli/stock/getprices").success(function (data) {
                    $scope.pricemap=data.data;
                })
            };
            //删除uid的cookie
            $scope.delCookie = function () {
                $.removeCookie('stock_user_id',{ path: '/'});
                $.removeCookie("stock_user_role",{path:'/'});
            }
        });
    </script>

    <!-- Custom fonts for this template -->
    <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
          rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="css/sb-admin-2.min.css" rel="stylesheet">

    <!-- Custom styles for this page -->
    <link href="vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">

</head>

<body id="page-top" ng-app="myApp" ng-controller="myCtrl">

<!-- Page Wrapper -->
<div id="wrapper">

    <!-- 侧边栏开始 -->
    <ul class="navbar-nav bg-gray-800 sidebar sidebar-dark accordion" id="accordionSidebar">

        <!-- 公司logo与公司名区域 -->
        <a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.html">
            <div class="sidebar-brand-icon rotate-n-15">
                <i class="fas fa-laugh-wink"></i>
            </div>
            <div class="sidebar-brand-text mx-3">金正股份<sup>TM</sup></div>
        </a>

        <!-- 分割线 -->
        <hr class="sidebar-divider my-0">

        <!-- 首页模块 -->
        <li class="nav-item active">
            <a class="nav-link" href="index.html">
                <i class="fas fa-fw fa-tachometer-alt"></i>
                <span>首页</span></a>
        </li>

        <!-- 分割线 -->
        <hr class="sidebar-divider">

        <!-- 股票行情头标题 -->
        <div class="sidebar-heading">
            股票市场
        </div>

        <!-- 热门股票模块 -->
        <li class="nav-item">
            <a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapseTwo"
               aria-expanded="true" aria-controls="collapseTwo">

                <i class="fas fa-fire fa-cog"></i>

                <span>热门股票</span>
            </a>
   <!--         <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionSidebar">
                <div class="bg-white py-2 collapse-inner rounded">
                    <h6 class="collapse-header">Custom Components:</h6>
                    <a class="collapse-item" href="buttons.html">Buttons</a>
                    <a class="collapse-item" href="cards.html">Cards</a>
                </div>
            </div>-->
        </li>

        <!-- 股票行情模块 -->
        <li class="nav-item">
            <a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapseUtilities"
               aria-expanded="true" aria-controls="collapseUtilities">
                <i class="fas fa-fw fa-chart-area"></i>
                <span>股票行情</span>
            </a>
        <!--    <div id="collapseUtilities" class="collapse" aria-labelledby="headingUtilities"
                 data-parent="#accordionSidebar">
                <div class="bg-white py-2 collapse-inner rounded">
                    <h6 class="collapse-header">Custom Utilities:</h6>
                    <a class="collapse-item" href="market_K.html">K线图</a>
                    <a class="collapse-item" href="utilities-color.html">Colors</a>
                    <a class="collapse-item" href="utilities-border.html">Borders</a>
                    <a class="collapse-item" href="utilities-animation.html">Animations</a>
                    <a class="collapse-item" href="utilities-other.html">Other</a>
                </div>
            </div>-->
        </li>

        <!-- 分割线 -->
        <hr class="sidebar-divider">

        <!-- 交易系统头标题 -->
        <div class="sidebar-heading">
            交易中心
        </div>

        <!-- 股票买入模块 -->

        <li class="nav-item">
            <a class="nav-link" href="buy.html">
                <i class="fas fa-dollar-sign fa-2x"></i>
                <span>股票买入</span></a>
        </li>

        <!-- 股票卖出模块 -->
        <li class="nav-item">
            <a class="nav-link" href="maichu.html">
                <i class="fas fa-outdent"></i>
                <span>股票卖出</span></a>
        </li>

        <!-- 股票撤销模块 -->
        <li class="nav-item">
            <a class="nav-link" href="chedan.html">
                <i class="fas fa-window-close fa-table"></i>
                <span>股票撤销</span></a>
        </li>
        <!-- 分割线 -->
        <hr class="sidebar-divider bg-gray-800">
        <!--用户中心模块-->
        <div class="sidebar-heading">
            用户中心
        </div>
        <!-- 个人股票模块 -->
        <li class="nav-item">
            <a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapsePages"
               aria-expanded="true" aria-controls="collapsePages">
                <i class="fas fa-warehouse fa-folder"></i>
                <span>我的股票</span>
            </a>
            <div id="collapsePages" class="collapse" aria-labelledby="headingPages" data-parent="#accordionSidebar">
                <div class="bg-gray-200 py-2 collapse-inner rounded">
                    <h6 class="collapse-header" style="color:gray">股仓</h6>
                    <a class="collapse-item" href="pos.html"> <i class="fas fa-arrow-right"></i>持仓</a>
                    <a class="collapse-item" href="chengjiao.html"> <i class="fas fa-arrow-right"></i>成交</a>
                    <a class="collapse-item" href="weituo.html"> <i class="fas fa-arrow-right"></i>委托</a>
                </div>
            </div>
        </li>
        <!-- 个人中心模块 -->
        <li class="nav-item">
            <a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#center" aria-expanded="true" aria-controls="center">
                <i class="fas fa-user-astronaut fa-folder"></i>
                <span>个人中心</span>
            </a>
            <div id="center" class="collapse" aria-labelledby="headingPages" data-parent="#accordionSidebar">
                <div class="bg-gray-200 py-2 collapse-inner rounded">
                    <a class="collapse-item" href="setting.html"> <i class="fas fa-user-cog">&nbsp;</i>设置</a>
                    <a class="collapse-item" href="wallet.html"> <i class="fas fa-wallet">&nbsp;</i>钱包</a>
                </div>
            </div>
        </li>
        <!-- Divider -->
        <hr class="sidebar-divider d-none d-md-block">

        <!-- Sidebar Toggler (Sidebar) -->
        <div class="text-center d-none d-md-inline">
            <button class="rounded-circle border-0" id="sidebarToggle"></button>
        </div>

    </ul>
    <!-- End of Sidebar -->

    <!-- Content Wrapper -->
    <div id="content-wrapper" class="d-flex flex-column">

        <!-- Main Content -->
        <div id="content">

            <!-- Topbar -->
            <nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">

                <!-- Sidebar Toggle (Topbar) -->
                <form class="form-inline">
                    <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
                        <i class="fa fa-bars"></i>
                    </button>
                </form>

                <!--
                          &lt;!&ndash; Topbar Search &ndash;&gt;
                          <form class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100 navbar-search">
                            <div class="input-group">
                              <input type="text" class="form-control bg-light border-0 small" placeholder="Search for..." aria-label="Search" aria-describedby="basic-addon2">
                              <div class="input-group-append">
                                <button class="btn btn-primary" type="button">
                                  <i class="fas fa-search fa-sm"></i>
                                </button>
                              </div>
                            </div>
                          </form>
                -->

                <!-- Topbar Navbar -->
                <ul class="navbar-nav ml-auto">

                    <!-- Nav Item - Search Dropdown (Visible Only XS) -->
                    <li class="nav-item dropdown no-arrow d-sm-none">
                        <a class="nav-link dropdown-toggle" href="#" id="searchDropdown" role="button"
                           data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <!-- Dropdown - Messages -->
                        <div class="dropdown-menu dropdown-menu-right p-3 shadow animated--grow-in"
                             aria-labelledby="searchDropdown">
                            <form class="form-inline mr-auto w-100 navbar-search">
                                <div class="input-group">
                                    <input type="text" class="form-control bg-light border-0 small"
                                           placeholder="Search for..." aria-label="Search"
                                           aria-describedby="basic-addon2">
                                    <div class="input-group-append">
                                        <button class="btn btn-primary" type="button">
                                            <i class="fas fa-search fa-sm"></i>
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </li>
                    <!-- 个人中心模块 -->
                    <li class="nav-item dropdown no-arrow">
                        <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <span class="mr-2 d-none d-lg-inline text-gray-600 small">我的账户</span>
                            <img class="img-profile rounded-circle" src="img/headpic.jpg">
                        </a>
                        <!-- Dropdown - User Information -->
                        <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">
                            <a class="dropdown-item" href="openAccount.html">
                                <i class="fas fa-cogs fa-sm fa-fw mr-2 text-gray-400"></i>
                                开户
                            </a>
                            <a class="dropdown-item" href="login.html">
                                <i class="fas fa-user-circle fa-sm fa-fw mr-2 text-gray-400"></i>
                                登录
                            </a>
                            <a class="dropdown-item" href="register.html">
                                <i class="fas fa-user-plus fa-sm fa-fw mr-2 text-gray-400"></i>
                                注册
                            </a>
                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="#" data-toggle="modal" data-target="#logoutModal">
                                <i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i>
                                退出登录
                            </a>
                        </div>
                    </li>

                </ul>

            </nav>
            <!-- End of Topbar -->

            <!-- Begin Page Content -->
            <div class="container-fluid">

                <!-- Page Heading -->
                <!-- <h1 class="h3 mb-2 text-gray-800">Tables</h1>
                 <p class="mb-4">DataTables is a third party plugin that is used to generate the demo table below. For more information about DataTables, please visit the <a target="_blank" href="https://datatables.net">official DataTables documentation</a>.</p>-->

                <!-- DataTales Example -->
                <div class="card shadow mb-4">
                    <div class="card-header py-3">
                        <h6 class="m-0 font-weight-bold text-primary">个人持仓:</h6>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <form class="form-inline">
                                <span style="font-size: 13px">股票代码:&nbsp;<input class="form-control"
                                                                                style="height: 30px"
                                                                                ng-model="searchCode"></span>
                                &nbsp;<a href="#" class="btn btn-success btn-sm" ng-click="searchAll2()">点击查询</a>
                            </form>
                            <h1></h1>
                            <table class="table table-bordered table-hover table-striped" width="100%" cellspacing="0"
                                   style="font-size: 12px">
                                <tr>
                                    <td>股票代码</td>
                                    <td>股票名称</td>
                                    <td>股票总额</td>
                                    <td>可用股数</td>
                                    <td>冻结股数</td>
                                    <td>成本价</td>

                                    <td>市价</td>
                                    <td>盈亏</td>
                                    <td>盈亏比例</td>
                                    <td>市值</td>
                                    <td>交易市场</td>
                                </tr>
                                <tr ng-repeat="u in list">
                                    <td>{{u.stockPosCode}}</td>
                                    <td>{{u.stockPosCompany}}</td>
                                    <td>{{u.stockPosTradblance}}</td>
                                    <td>{{u.stockPosKyblance}}</td>
                                    <td>{{u.stockPosDjblance}}</td>
                                    <td>{{u.stockPosMoney}}</td>

                                    <td>{{pricemap[u.stockPosCode]}}</td>
                                    <td>{{(u.stockPosMoney-pricemap[u.stockPosCode])*u.stockPosTradblance}}</td>
                                    <td>{{(u.stockPosMoney-pricemap[u.stockPosCode])/u.stockPosMoney}}</td>
                                    <td>{{u.stockPosTradblance*pricemap[u.stockPosCode]}}</td>
                                    <td>深交所</td>
                                </tr>
                                <tr>
                                    <td colspan="11">
                                        <!--自动分页标签-->
                                        <tm-pagination conf="paginationConf" style="font-size: 16px"></tm-pagination>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /.container-fluid -->

        </div>
        <!-- End of Main Content -->

        <!-- Footer -->
        <footer class="sticky-footer bg-white">
            <div class="container my-auto">
                <div class="copyright text-center my-auto">
                    <span>Copyright &copy; Your Website 2020</span>
                </div>
            </div>
        </footer>
        <!-- End of Footer -->

    </div>
    <!-- End of Content Wrapper -->

</div>
<!-- End of Page Wrapper -->

<!-- Scroll to Top Button-->
<a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
</a>

<!-- 退出登录模态框-->
<div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
     aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">系统消息</h5>
                <button class="close" type="button" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">如果您已经准备好结束当前的会话，请选择下面的“确定”</div>
            <div class="modal-footer">
                <button class="btn btn-secondary" type="button" data-dismiss="modal">取消</button>
                <a class="btn btn-primary" ng-click="delCookie()" href="login.html">确定</a>
            </div>
        </div>
    </div>
</div>

<!-- Bootstrap core JavaScript-->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="bootstrap/js/jquery-cookie/jquery.cookie.js"></script>

<!-- Core plugin JavaScript-->
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>

<!-- Custom scripts for all pages-->
<script src="js/sb-admin-2.min.js"></script>

<!-- Page level plugins -->
<script src="vendor/datatables/jquery.dataTables.min.js"></script>
<script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>

<!-- Page level custom scripts -->
<script src="js/demo/datatables-demo.js"></script>
<!--6.引入Layer框架的JS-->
<script src="layer/layer/layer.js"></script>
</body>

</html>
